package com.dating.pref;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;

import com.dating.activity.R;

public class Pref extends PreferenceActivity{
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		addPreferencesFromResource(R.xml.pref);

	}
	// AUTO LOGIN
		public static final boolean OPT_AUTO_DEF = false;
		public static final String OPT_AUTO = "autologin";
		
		public static boolean getAutoLogin(Context context) {
			return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(OPT_AUTO, OPT_AUTO_DEF);
		}

		public static void setAutoLogin(Context c, boolean auto) {
			SharedPreferences settings = PreferenceManager
					.getDefaultSharedPreferences(c);
			SharedPreferences.Editor edit = settings.edit();
			edit.putBoolean(Pref.OPT_AUTO, auto);
			edit.commit();
		}
	// PASSWORD
	public static final String OPT_PASS_DEF = "";
	public static final String OPT_PASS = "password";
	
	public static String getPassword(Context context) {
		return PreferenceManager.getDefaultSharedPreferences(context).getString(OPT_PASS, OPT_PASS_DEF);
	}

	public static void setPassword(Context c, String password) {
		SharedPreferences settings = PreferenceManager
				.getDefaultSharedPreferences(c);
		SharedPreferences.Editor edit = settings.edit();
		edit.putString(Pref.OPT_PASS, password);
		edit.commit();
	}
	// EMAIL
	public static final String OPT_EMAIL_DEF = "";
	public static final String OPT_EMAIL = "email";
	
	public static String getEmail(Context context) {
		return PreferenceManager.getDefaultSharedPreferences(context).getString(OPT_EMAIL, OPT_EMAIL_DEF);
	}

	public static void setEmail(Context c, String email) {
		SharedPreferences settings = PreferenceManager
				.getDefaultSharedPreferences(c);
		SharedPreferences.Editor edit = settings.edit();
		edit.putString(Pref.OPT_EMAIL, email);
		edit.commit();
	}
	// AUTH
	public static final String OPT_AUTH_DEF = "";
	public static final String OPT_AUTH = "auth";
	
	public static String getAuth(Context context) {
		return PreferenceManager.getDefaultSharedPreferences(context).getString(OPT_AUTH, OPT_AUTH_DEF);
	}

	public static void setAuth(Context c, String email) {
		SharedPreferences settings = PreferenceManager
				.getDefaultSharedPreferences(c);
		SharedPreferences.Editor edit = settings.edit();
		edit.putString(Pref.OPT_AUTH, email);
		edit.commit();
	}
	// USID
	public static final String OPT_UID_DEF = "";
	public static final String OPT_UID = "usid";
	
	public static String getUsid(Context context) {
		return PreferenceManager.getDefaultSharedPreferences(context).getString(OPT_UID, OPT_UID_DEF);
	}

	public static void setUsid(Context c, String email) {
		SharedPreferences settings = PreferenceManager
				.getDefaultSharedPreferences(c);
		SharedPreferences.Editor edit = settings.edit();
		edit.putString(Pref.OPT_UID, email);
		edit.commit();
	}
	
	//DISTANCE
	public static final String OPT_DST_DEF = "99999";
	public static final String OPT_DST = "distance";
	
	public static String getDistance(Context context) {
		return PreferenceManager.getDefaultSharedPreferences(context).getString(OPT_DST, OPT_DST_DEF);
	}

	public static void setDistance(Context c, String distance) {
		SharedPreferences settings = PreferenceManager
				.getDefaultSharedPreferences(c);
		SharedPreferences.Editor edit = settings.edit();
		edit.putString(Pref.OPT_DST, distance);
		edit.commit();
	}
	
	//OFFSET
	public static final String OPT_OST_DEF = "0";
	public static final String OPT_OST = "offset";
	
	public static String getOffset(Context context) {
		return PreferenceManager.getDefaultSharedPreferences(context).getString(OPT_OST, OPT_OST_DEF);
	}

	public static void setOffset(Context c, String offset) {
		SharedPreferences settings = PreferenceManager
				.getDefaultSharedPreferences(c);
		SharedPreferences.Editor edit = settings.edit();
		edit.putString(Pref.OPT_OST, offset);
		edit.commit();
	}
	//OFFSET
	public static final String OPT_LEN_DEF = "10";
	public static final String OPT_LEN = "lenght";
	
	public static String getLenght(Context context) {
		return PreferenceManager.getDefaultSharedPreferences(context).getString(OPT_LEN, OPT_LEN_DEF);
	}

	public static void setLenght(Context c, String lenght) {
		SharedPreferences settings = PreferenceManager
				.getDefaultSharedPreferences(c);
		SharedPreferences.Editor edit = settings.edit();
		edit.putString(Pref.OPT_LEN, lenght);
		edit.commit();
	}
}
